package com.zone.gateway.center.config;

import com.zone.gateway.common.response.Result;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author: zongzi
 * @description: 全局异常处理器
 * @date: 2024/6/18
 */
@RestControllerAdvice
public class GatewayCenterGlobalExceptionHandler {
    private final Logger logger = LoggerFactory.getLogger(GatewayCenterGlobalExceptionHandler.class);

//    @ExceptionHandler(BizException.class)
//    public Response<Object> bizExceptionHandler(BizException e) {
//        return Response.builder()
//                .code(e.getResponseCode().getCode())
//                .info(e.getErrorMsg())
//                .build();
//    }

    @ExceptionHandler(Exception.class)
    public Result<Object> exceptionHandler(Exception e) {
        logger.error("网关中心执行异常：", e);
        return Result.error(e.getMessage());
    }
}
